﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:l="http://wpflocalizeextension.codeplex.com"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Common="http://imagin.tech/imagin/common"
    xmlns:Controls.Extended="http://imagin.tech/imagin/controls/extended">
    <Common:ObjectToTypeConverter x:Key="ObjectToTypeConverter"/>
    <Common:StringToCamelCaseConverter x:Key="StringToCamelCaseConverter"/>

    <Style x:Key="{x:Type Controls.Extended:PropertyGrid}" TargetType="{x:Type Controls.Extended:PropertyGrid}">
        <Setter Property="Foreground" Value="{DynamicResource Brush.Text}"/>
        <Setter Property="DescriptionTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border
                        Background="{DynamicResource Brush.PropertyGrid.Description.Background}"
                        TextElement.Foreground="{DynamicResource Brush.Text}"
                        Padding="10">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <TextBlock 
                                FontWeight="Bold"
                                Margin="0,0,0,7"
                                Text="{Binding Name, Converter={StaticResource StringToCamelCaseConverter}, Mode=OneWay}"
                                TextTrimming="CharacterEllipsis"/>
                            <TextBlock 
                                Grid.Row="1"
                                Text="{Binding Description, Mode=OneWay}"
                                TextTrimming="CharacterEllipsis"
                                TextWrapping="Wrap"
                                ToolTip="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}"/>
                        </Grid>
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="GridStyle">
            <Setter.Value>
                <Style TargetType="{x:Type DataGrid}">
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="BorderBrush" Value="Transparent"/>
                    <Setter Property="BorderThickness" Value="0"/>
                    <Setter Property="CanUserReorderColumns" Value="False"/>
                    <Setter Property="CanUserResizeColumns" Value="True"/>
                    <Setter Property="CanUserResizeRows" Value="False"/>
                    <Setter Property="EnableColumnVirtualization" Value="True"/>
                    <Setter Property="EnableRowVirtualization" Value="True"/>
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Padding" Value="0"/>
                    <Setter Property="VirtualizingPanel.IsContainerVirtualizable" Value="True"/>
                    <Setter Property="VirtualizingPanel.IsVirtualizing" Value="True"/>
                    <Setter Property="VirtualizingPanel.VirtualizationMode" Value="Recycling"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="NestedPropertyTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Button
                        Command="{Binding NestCommand, RelativeSource={RelativeSource AncestorType={x:Type Controls.Extended:PropertyGrid}}}"
                        CommandParameter="{Binding Value, Mode=OneWay}"
                        Content="{l:Loc Edit}"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="SplitterStyle">
            <Setter.Value>
                <Style TargetType="GridSplitter">
                    <Setter Property="Background" Value="{DynamicResource Brush.GridSplitter.Background}" />
                    <Setter Property="Height" Value="3"/>
                    <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    <Setter Property="ResizeBehavior" Value="PreviousAndNext" />
                    <Setter Property="VerticalAlignment" Value="Top"/>
                    <Setter Property="Width" Value="Auto"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="TypeTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock 
                        FontWeight="Bold"
                        Margin="10,5"
                        Text="{Binding Mode=OneWay, Converter={StaticResource ObjectToTypeConverter}}"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>